package cn.mrcode.fd.blog.listener;

import cn.mrcode.fd.utils.log.track.LogTrackTemplateUtil;
import com.alibaba.fastjson.JSONObject;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.SessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * session监听器
 * @author : zhuqiang
 * @version : V1.0
 * @date : 2016/3/7 22:13
 */
public class BlogSessionListener implements SessionListener{
    private Logger log = LoggerFactory.getLogger(InitListener.class);
    private String apiName = "session监听器";
    @Override
    public void onStart(Session session) {
        log.error(LogTrackTemplateUtil.svMsg(apiName,"session创建=%s,id=%s", JSONObject.toJSONString(session),session.getId()+""));
    }

    @Override
    public void onStop(Session session) {
        log.info(LogTrackTemplateUtil.svMsg(apiName,"session销毁=%s", JSONObject.toJSONString(session)));
    }

    @Override
    public void onExpiration(Session session) {
        log.error(LogTrackTemplateUtil.svMsg(apiName,"session超时=%s", JSONObject.toJSONString(session)));
    }
}
